package com.gaogzhen.security.syn;

public class Account {
    private int money;
    public  Account(int money) {
        this.money = money;
    }

    public int getMoney() { return this.money;}

    public void setMoney(int money) { this.money = money;}

    public  void transfer(Account account, int amount) {
        synchronized (Account.class) {
            if (this.money >= amount) {
                this.setMoney(this.getMoney() - amount);
                account.setMoney(account.getMoney() + amount);
            }
        }
    }
}
